package de.openlaboratory.xmleditor.servlet.view.menu;

import java.util.ArrayList;

public class MenuItem
{
	private String name;        // internal name
	private String action;      // (form) action associated with that menu item
	private String text;        // menu item text output
	private String description; // p.e. hover
	private String link;        // target of item
	private boolean active;     // display state (clickable or similar) 
	
	ArrayList<MenuItem> subItems;

	public MenuItem(String action, String text, String link)
	{
		this.action = action;
		this.text = text;
		this.link = link;
		
		this.description = text;
		this.active = true;
	}
	
	public String outputHtml()
	{
		StringBuilder s = new StringBuilder();
		
		s.append("<span>");
		
		if(active)
		{		
			s.append("<a ");
			s.append("href=\"").append(link).append("\"");
			s.append(">");
		}
		
		s.append(text);
		
		if(active)
			s.append("</a>");
		
		s.append("</span><br />");
		
		return s.toString();
	}
}
